home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / udev.postinst < prev    next >
Encoding:
Text File  |  2007-04-10  |  3.9 KB  |  175 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # After the package was installed:
  5. #    <postinst> configure <old-version>
  6. #
  7. #
  8. # If prerm fails during upgrade or fails on failed upgrade:
  9. #    <old-postinst> abort-upgrade <new-version>
  10. #
  11. # If prerm fails during deconfiguration of a package:
  12. #    <postinst> abort-deconfigure in-favour <new-package> <version>
  13. #               removing <old-package> <version>
  14. #
  15. # If prerm fails during replacement due to conflict:
  16. #    <postinst> abort-remove in-favour <new-package> <version>
  17.  
  18.  
  19. # Remove a no-longer used conffile
  20. rm_conffile()
  21. {
  22.     CONFFILE="$1"
  23.  
  24.     if [ -e "$CONFFILE".dpkg-obsolete ]; then
  25.     echo "Removing obsolete conffile $CONFFILE"
  26.     rm -f "$CONFFILE".dpkg-obsolete
  27.     fi
  28. }
  29.  
  30. # Remove a conffile directory if it's not empty
  31. rm_confdir()
  32. {
  33.     CONFDIR="$1"
  34.  
  35.     if [ -d "$CONFDIR" ]; then
  36.     rmdir "$CONFDIR" 2>/dev/null \
  37.         || echo "Unable to remove $CONFDIR, not empty"
  38.     fi
  39. }
  40.  
  41. # Move a conffile without triggering a dpkg question
  42. mv_conffile() {
  43.     OLDCONFFILE="$1"
  44.     NEWCONFFILE="$2"
  45.  
  46.     if [ -e "$OLDCONFFILE".dpkg-moving ]; then
  47.         echo "Preserving user changes to $NEWCONFFILE"
  48.         mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
  49.         mv -f "$OLDCONFFILE".dpkg-moving "$NEWCONFFILE"
  50.     elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
  51.     rm -f "$OLDCONFFILE".dpkg-bak
  52.     fi
  53. }
  54.  
  55.  
  56. # Construct the initial device tree (things udev doesn't provide)
  57. create_devices()
  58. {
  59.     rm -f /lib/udev/devices/fd
  60.     ln -sn /proc/self/fd   /lib/udev/devices/fd
  61.  
  62.     rm -f /lib/udev/devices/stdin
  63.     ln -sn /proc/self/fd/0 /lib/udev/devices/stdin
  64.  
  65.     rm -f /lib/udev/devices/stdout
  66.     ln -sn /proc/self/fd/1 /lib/udev/devices/stdout
  67.  
  68.     rm -f /lib/udev/devices/stderr
  69.     ln -sn /proc/self/fd/2 /lib/udev/devices/stderr
  70.  
  71.     rm -f /lib/udev/devices/core
  72.     ln -sn /proc/kcore     /lib/udev/devices/core
  73.  
  74.     rm -f /lib/udev/devices/sndstat
  75.     ln -sn /proc/asound/oss/sndstat /lib/udev/devices/sndstat
  76.  
  77.     rm -f /lib/udev/devices/MAKEDEV
  78.     ln -sn /sbin/MAKEDEV   /lib/udev/devices/MAKEDEV
  79.  
  80.     rm -f /lib/udev/devices/ppp
  81.     mknod -m 600 /lib/udev/devices/ppp c 108 0
  82.  
  83.     rm -f /lib/udev/devices/loop0
  84.     mknod -m 600 /lib/udev/devices/loop0 b 7 0
  85.  
  86.     rm -f /lib/udev/devices/net/tun
  87.     mknod -m 600 /lib/udev/devices/net/tun c 10 200
  88.  
  89.     rm -f /lib/udev/devices/kmem
  90.     mknod -m 640 /lib/udev/devices/kmem c 1 2
  91.     chgrp kmem /lib/udev/devices/kmem
  92.  
  93.     # Add devices we need to start udevd itself
  94.     rm -f /lib/udev/devices/console
  95.     mknod -m 600 /lib/udev/devices/console c 5 1
  96.  
  97.     rm -f /lib/udev/devices/null
  98.     mknod -m 600 /lib/udev/devices/null c 1 3
  99.  
  100. }
  101.  
  102. # Add groups that we use
  103. add_groups()
  104. {
  105.     for GROUP in scanner nvram; do
  106.     if [ -z "$(getent group $GROUP)" ]; then
  107.         echo "Adding $GROUP group..."
  108.         addgroup --quiet --system $GROUP || true
  109.     fi
  110.     done
  111. }
  112.  
  113. # Notify the user that a reboot is required
  114. reboot_required()
  115. {
  116.     if [ -x /usr/share/update-notifier/notify-reboot-required ]; then
  117.     /usr/share/update-notifier/notify-reboot-required
  118.     fi
  119. }
  120.  
  121. # Update the initramfs
  122. update_initramfs()
  123. {
  124.     update-initramfs -u
  125. }
  126.  
  127. # Rename the persistent-disk.rules file
  128. mv_persistent_disk_rules()
  129. {
  130.     mv_conffile /etc/udev/rules.d/65-persistent-disk.rules \
  131.             /etc/udev/rules.d/65-persistent-storage.rules
  132. }
  133.  
  134. # Rename the cdrom_id.rules file
  135. mv_cdrom_id_rules()
  136. {
  137.     mv_conffile /etc/udev/rules.d/50-cdrom_id.rules \
  138.             /etc/udev/rules.d/30-cdrom_id.rules
  139. }
  140.  
  141.  
  142. case "$1" in
  143.     configure)
  144.     # Upgrade from dapper
  145.     if dpkg --compare-versions "$2" lt "093-0ubuntu1"; then
  146.         mv_persistent_disk_rules
  147.     fi
  148.  
  149.     # Upgrade within feisty development cycle
  150.     if dpkg --compare-versions "$2" lt "108-0ubuntu1"; then
  151.         mv_cdrom_id_rules
  152.     fi
  153.  
  154.     create_devices
  155.     add_groups
  156.     update_initramfs
  157.     ;;
  158.  
  159.     abort-upgrade|abort-deconfigure|abort-remove)
  160.     ;;
  161.  
  162.     *)
  163.     echo "$0 called with unknown argument \`$1'" 1>&2
  164.     exit 1
  165.     ;;
  166. esac
  167.  
  168. # Automatically added by dh_installinit
  169. if [ -x "/etc/init.d/udev" ]; then
  170.     update-rc.d udev start 10 S . >/dev/null || exit $?
  171. fi
  172. # End automatically added section
  173.  
  174. exit 0
  175.